﻿<Window x:Class="CncConvProg.View.Dialog.MaterialsDialogView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ab="clr-namespace:CncConvProg.View.AttachedProperty" xmlns:Resources="clr-namespace:MecPrev.Resources;assembly=MecPrev.Resources" 
        Title="{x:Static Resources:GuiRes.dlgMaterial}" 
        WindowStyle="ToolWindow"
        WindowState="Normal"
        MinHeight="200" MinWidth="300"
        Width="640"
        Height="480"
        WindowStartupLocation="CenterScreen"
        >
    <Window.Resources>
        <Style TargetType="{x:Type ListViewItem}">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="396*" />
            <RowDefinition Height="45*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width=".25*" MinWidth="250"  />
            <ColumnDefinition Width=".75*" MinWidth="250" />
        </Grid.ColumnDefinitions>

        <!-- Lista Utensili -->
        <Border x:Name="Colonna_SX" Padding="4" Grid.RowSpan="1">
            <DockPanel>
                <ListView ItemsSource="{Binding Path= Materiali}" SelectionMode="Single" SelectedItem="{Binding Path=MaterialeSelezionato}" >
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Header="{x:Static Resources:GuiRes.Description}" DisplayMemberBinding="{Binding Path=Descrizione}" Width="190"/>
                        </GridView>
                    </ListView.View>
                </ListView>
            </DockPanel>
        </Border>

        <GridSplitter Width="2" Height="250" Margin="0,96,0,50" />

        <!-- Dettagli Utensile -->
        <Border x:Name="Colonna_DX" Grid.Column="1" Margin="2,5,5,5" BorderThickness="2" Grid.RowSpan="1">
            <DockPanel>
                <Menu DockPanel.Dock="Top" HorizontalAlignment="Left">
                    <MenuItem Header="{x:Static Resources:GuiRes.btnAddMaterial}" Command="{Binding Path=NewMaterialCmd}"  />
                    <MenuItem Header="{x:Static Resources:GuiRes.btnDelMateriale}" Command="{Binding Path=DelMaterialCmd}" />
                </Menu>
                <StackPanel>
                    <StackPanel DockPanel.Dock="Top" DataContext="{Binding Path=MaterialeSelezionato}">
                        <TextBlock Text="{x:Static Resources:GuiRes.MaterialGroup}"/>
                        <ComboBox ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}},Path=DataContext.GruppiMaterialeLookup}" 
                                          SelectedValue="{Binding Path= GruppoMateriale}"
                                          Height="40"   
                                          Width="250"
                                          SelectedValuePath="Key" 
                                          Margin="2" 
                                          HorizontalAlignment="Left">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <Border Padding="2" Margin="2">
                                        <StackPanel Orientation="Horizontal">
                                            <Image Width="22" Height="22" >
                                                <Image.Style>
                                                    <Style>
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding Path=Key}" Value="0">
                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_p.png"/>
                                                            </DataTrigger>

                                                            <DataTrigger Binding="{Binding Path= Key}" Value="1">
                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_m.png"/>
                                                            </DataTrigger>

                                                            <DataTrigger Binding="{Binding Path=Key}" Value="2">
                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_k.png"/>
                                                            </DataTrigger>

                                                            <DataTrigger Binding="{Binding Path= Key}" Value="3">
                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_n.png"/>
                                                            </DataTrigger>

                                                            <DataTrigger Binding="{Binding Path=Key}" Value="4">
                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_h.png"/>
                                                            </DataTrigger>

                                                            <DataTrigger Binding="{Binding Path= Key}" Value="5">
                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_s.png"/>
                                                            </DataTrigger>

                                                            <DataTrigger Binding="{Binding Path= Key}" Value="6">
                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_n.png"/>
                                                            </DataTrigger>

                                                        </Style.Triggers>
                                                    </Style>
                                                </Image.Style>
                                            </Image>
                                            <TextBlock Text="{Binding Path=Value}" VerticalAlignment="Center" Margin="3"/>
                                        </StackPanel>
                                    </Border>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                        <StackPanel Orientation="Horizontal" Margin="5">
                            <TextBlock Text="{x:Static Resources:GuiRes.Description}" Margin="4" MinWidth="120" />
                            <TextBox Text="{Binding Path=Descrizione}" ab:AutoSelectTextBox.AutoSelectText="True"   MinWidth="150" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="5">
                            <TextBlock Text="{x:Static Resources:GuiRes.pesoSpecifico}" Margin="4" MinWidth="120" />
                            <TextBox Text="{Binding Path=PesoSpecifico}" ab:AttachedProperties.AutoSelectText="True" MinWidth="150" />
                        </StackPanel>
                    </StackPanel>
                    <Menu DockPanel.Dock="Top" HorizontalAlignment="Left" Margin="5">
                        <MenuItem Header="{x:Static Resources:GuiRes.btnAddPrice}" Command="{Binding Path=NewPrezzoCmd}"  />
                        <MenuItem Header="{x:Static Resources:GuiRes.btnDelPrice}" Command="{Binding Path=DelPrezzoCmd}" />
                    </Menu>
                    <ListView  Margin="5" ItemsSource="{Binding Path= PrezziMateriale}" SelectionMode="Single" SelectedItem="{Binding Path=PrezzoMaterialeSelezionato}" >
                        <ListView.View>
                            <GridView>
                                <GridViewColumn Header="{x:Static Resources:GuiRes.Description}" Width="210">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBox Text="{Binding Path=Descrizione}" ab:AutoSelectTextBox.AutoSelectText="True"   />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="€/Kg" Width="50">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBox Text="{Binding Path=Prezzo}" ab:AttachedProperties.AutoSelectText="True"/>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView>
                        </ListView.View>
                    </ListView>

                </StackPanel>
            </DockPanel>
        </Border>

        <StackPanel Orientation="Horizontal" Grid.Row="3" HorizontalAlignment="Right" Grid.ColumnSpan="2" >
            <Button Content="{x:Static Resources:GuiRes.ButtonCancel}" Width="100" Margin="5" Click="Button_Click_1" />
            <Button Content="Ok" Width="100" Margin="5" Click="Button_Click" />
        </StackPanel>
    </Grid>

</Window>
